<template>
<div>
  <center>
  <h1>融资申请审核</h1>
  </center>
<!--  <el-row :gutter="10" class="mb8">-->
<!--    <el-col :span="1.5">-->
<!--      <el-button-->
<!--        type="primary"-->
<!--        plain-->
<!--        icon="el-icon-plus"-->
<!--        size="mini"-->
<!--        @click="handleAdd"-->
<!--        v-hasPermi="['ruoyi-business:business:add']"-->
<!--      >新增</el-button>-->
<!--    </el-col>-->
<!--  </el-row>-->
  <el-table :data="installmentList">
    <el-table-column type="selection" width="55" align="center" />
    <el-table-column label="ID" align="center" prop="id" />
    <el-table-column label="房租分期申请单号" align="center" prop="rentInstallmentOrderNo" />
    <el-table-column label="外部合同号" align="center" prop="outOrderNo" />
    <el-table-column label="部门编号" align="center" prop="deptNo" />
    <el-table-column label="利率" align="center" prop="rate" />
    <el-table-column label="租客承担比例" align="center" prop="tenantRate" />
    <el-table-column label="公寓承担比例" align="center" prop="businessRate" />
    <el-table-column label="借款金额" align="center" prop="loanAmount" />
    <el-table-column label="借款期限" align="center" prop="monthLimit" />
    <el-table-column label="一次性服务费" align="center" prop="serviceFee" />
    <el-table-column label="金融产品ID" align="center" prop="jrProductId" />
    <el-table-column label="应收租金合计" align="center" prop="reLeaseCount" />
    <el-table-column label="公寓分期利息合计" align="center" prop="inInterestCount" />
    <el-table-column label="服务费" align="center" prop="serCharge" />
    <el-table-column label="备注" align="center" prop="remarks" />
    <el-table-column label="状态" align="center" prop="applyState" >
      <template slot-scope="scope">
        <span v-if="scope.row.applyState===1">申请中</span>
        <span v-if="scope.row.applyState===2">初审通过</span>
        <span v-if="scope.row.applyState===3">初审不通过</span>
        <span v-if="scope.row.applyState===4">复审通过</span>
        <span v-if="scope.row.applyState===5">复审不通过</span>
      </template>
    </el-table-column>
    <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
      <template slot-scope="scope">
        <span v-if="scope.row.applyState===1">
            <el-button
              type="text"
              plain
              icon="el-icon-edit"
              size="mini"
              @click="goUpdateStatus(scope.row)"
            >审核</el-button>
          </span>
        <span v-if="scope.row.applyState===2">
            <el-button
              type="text"
              plain
              icon="el-icon-edit"
              size="mini"
              @click="goUpdateStatus(scope.row)"
            >复审</el-button>
          </span>
        <span v-if="scope.row.applyState===3">
            <el-button
              type="text"
              plain
              icon="el-icon-edit"
              size="mini"
              @click="get(scope.row)"
            >查看</el-button>
          </span>
        <span v-if="scope.row.applyState===5">
            <el-button
              type="text"
              plain
              icon="el-icon-edit"
              size="mini"
              @click="get(scope.row)"
            >查看</el-button>
          </span>
        <span v-if="scope.row.applyState===4">
            <el-button
              type="text"
              plain
              icon="el-icon-edit"
              size="mini"
              @click="get(scope.row)"
            >查看</el-button>
          </span>
      </template>
    </el-table-column>
  </el-table>

  <pagination
    v-show="total>0"
    :total="total"
    :page.sync="queryParams.pageNum"
    :limit.sync="queryParams.pageSize"
    @pagination="getList"
  />
  <!-- 审核对话框 -->
  <el-dialog :title="title2" :visible.sync="dialog" width="500px" append-to-body>
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-form-item label="房租分期申请单号" prop="rentInstallmentOrderNo">
        <el-input v-model="form.rentInstallmentOrderNo" placeholder="请输入房租分期申请单号" disabled="disabled" />
      </el-form-item>
      <el-form-item label="外部合同号" prop="outOrderNo">
        <el-input v-model="form.outOrderNo" placeholder="请输入外部合同号" disabled="disabled" />
      </el-form-item>
      <el-form-item label="商户ID" prop="bussinessId">
        <el-input v-model="form.bussinessId" placeholder="请输入商户ID" disabled="disabled" />
      </el-form-item>
      <el-form-item label="部门ID" prop="deptId">
        <el-input v-model="form.deptId" placeholder="请输入部门ID" disabled="disabled" />
      </el-form-item>
      <el-form-item label="部门编号" prop="deptNo">
        <el-input v-model="form.deptNo" placeholder="请输入部门编号" disabled="disabled" />
      </el-form-item>
      <el-form-item label="出房合同ID" prop="cfContractId">
        <el-input v-model="form.cfContractId" placeholder="请输入出房合同ID" disabled="disabled" />
      </el-form-item>
      <el-form-item label="利率" prop="rate">
        <el-input v-model="form.rate" placeholder="请输入利率" disabled="disabled" />
      </el-form-item>
      <el-form-item label="租客承担比例" prop="tenantRate">
        <el-input v-model="form.tenantRate" placeholder="请输入租客承担比例" disabled="disabled" />
      </el-form-item>
      <el-form-item label="公寓承担比例" prop="businessRate">
        <el-input v-model="form.businessRate" placeholder="请输入公寓承担比例" disabled="disabled" />
      </el-form-item>
      <el-form-item label="借款金额" prop="loanAmount">
        <el-input v-model="form.loanAmount" placeholder="请输入借款金额" disabled="disabled"  />
      </el-form-item>
      <el-form-item label="借款期限" prop="monthLimit">
        <el-input v-model="form.monthLimit" placeholder="请输入借款期限" disabled="disabled" />
      </el-form-item>
      <el-form-item label="一次性服务费" prop="serviceFee">
        <el-input v-model="form.serviceFee" placeholder="请输入一次性服务费" disabled="disabled" />
      </el-form-item>
      <el-form-item label="金融产品ID" prop="jrProductId">
        <el-input v-model="form.jrProductId" placeholder="请输入金融产品ID" disabled="disabled" />
      </el-form-item>
      <el-form-item label="应收租金合计" prop="reLeaseCount">
        <el-input v-model="form.reLeaseCount" placeholder="请输入应收租金合计" disabled="disabled" />
      </el-form-item>
      <el-form-item label="公寓分期利息合计" prop="inInterestCount">
        <el-input v-model="form.inInterestCount" placeholder="请输入公寓分期利息合计" disabled="disabled" />
      </el-form-item>
      <el-form-item label="服务费" prop="serCharge">
        <el-input v-model="form.serCharge" placeholder="请输入服务费" disabled="disabled" />
      </el-form-item>
      <el-form-item label="实收分期后租金合计" prop="coHirerentCount">
        <el-input v-model="form.coHirerentCount" placeholder="请输入实收分期后租金合计" disabled="disabled" />
      </el-form-item>
      <el-form-item label="备注" prop="remarks">
        <el-input v-model="form.remarks" type="textarea" placeholder="请输入内容" disabled="disabled" />
      </el-form-item>
      <el-form-item label="审核备注" prop="auditMemo">
        <el-input v-model="form.auditMemo" type="textarea" placeholder="请输入内容" disabled="disabled" />
      </el-form-item>

      <el-form-item label="状态" prop="applyState">
        <el-input v-model="form.applyState===1?'申请中':form.applyState===2?'初审通过':form.applyState===3?'初审不通过':form.applyState===4?'复审通过':form.applyState===5?'复审不通过':''"placeholder="请输入创建用户ID" disabled="disabled" />
      </el-form-item>
      <el-form-item label="创建用户ID" prop="createUserid">
        <el-input v-model="form.createUserid" placeholder="请输入创建用户ID" disabled="disabled" />
      </el-form-item>
      <el-form-item label="更新用户ID" prop="updateUserid">
        <el-input v-model="form.updateUserid" placeholder="请输入更新用户ID" disabled="disabled" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="updateStatus">同 意 审 核</el-button>
      <el-button type="primary" @click="updateStatus2">不 同 意 审 核</el-button>
    </div>
  </el-dialog>



  <el-dialog :title="title1" :visible.sync="dialog2" width="500px" append-to-body>
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-form-item label="房租分期申请单号" prop="rentInstallmentOrderNo">
        <el-input v-model="form.rentInstallmentOrderNo" placeholder="请输入房租分期申请单号" disabled="disabled" />
      </el-form-item>
      <el-form-item label="外部合同号" prop="outOrderNo">
        <el-input v-model="form.outOrderNo" placeholder="请输入外部合同号" disabled="disabled" />
      </el-form-item>
      <el-form-item label="商户ID" prop="bussinessId">
        <el-input v-model="form.bussinessId" placeholder="请输入商户ID" disabled="disabled" />
      </el-form-item>
      <el-form-item label="部门ID" prop="deptId">
        <el-input v-model="form.deptId" placeholder="请输入部门ID" disabled="disabled" />
      </el-form-item>
      <el-form-item label="部门编号" prop="deptNo">
        <el-input v-model="form.deptNo" placeholder="请输入部门编号" disabled="disabled" />
      </el-form-item>
      <el-form-item label="出房合同ID" prop="cfContractId">
        <el-input v-model="form.cfContractId" placeholder="请输入出房合同ID" disabled="disabled" />
      </el-form-item>
      <el-form-item label="利率" prop="rate">
        <el-input v-model="form.rate" placeholder="请输入利率" disabled="disabled" />
      </el-form-item>
      <el-form-item label="租客承担比例" prop="tenantRate">
        <el-input v-model="form.tenantRate" placeholder="请输入租客承担比例" disabled="disabled" />
      </el-form-item>
      <el-form-item label="公寓承担比例" prop="businessRate">
        <el-input v-model="form.businessRate" placeholder="请输入公寓承担比例" disabled="disabled" />
      </el-form-item>
      <el-form-item label="借款金额" prop="loanAmount">
        <el-input v-model="form.loanAmount" placeholder="请输入借款金额" disabled="disabled"  />
      </el-form-item>
      <el-form-item label="借款期限" prop="monthLimit">
        <el-input v-model="form.monthLimit" placeholder="请输入借款期限" disabled="disabled" />
      </el-form-item>
      <el-form-item label="一次性服务费" prop="serviceFee">
        <el-input v-model="form.serviceFee" placeholder="请输入一次性服务费" disabled="disabled" />
      </el-form-item>
      <el-form-item label="金融产品ID" prop="jrProductId">
        <el-input v-model="form.jrProductId" placeholder="请输入金融产品ID" disabled="disabled" />
      </el-form-item>
      <el-form-item label="应收租金合计" prop="reLeaseCount">
        <el-input v-model="form.reLeaseCount" placeholder="请输入应收租金合计" disabled="disabled" />
      </el-form-item>
      <el-form-item label="公寓分期利息合计" prop="inInterestCount">
        <el-input v-model="form.inInterestCount" placeholder="请输入公寓分期利息合计" disabled="disabled" />
      </el-form-item>
      <el-form-item label="服务费" prop="serCharge">
        <el-input v-model="form.serCharge" placeholder="请输入服务费" disabled="disabled" />
      </el-form-item>
      <el-form-item label="实收分期后租金合计" prop="coHirerentCount">
        <el-input v-model="form.coHirerentCount" placeholder="请输入实收分期后租金合计" disabled="disabled" />
      </el-form-item>
      <el-form-item label="备注" prop="remarks">
        <el-input v-model="form.remarks" type="textarea" placeholder="请输入内容" disabled="disabled" />
      </el-form-item>
      <el-form-item label="审核备注" prop="auditMemo">
        <el-input v-model="form.auditMemo" type="textarea" placeholder="请输入内容" disabled="disabled" />
      </el-form-item>

      <el-form-item label="状态" prop="applyState">
        <el-input v-model="form.applyState===1?'申请中':form.applyState===2?'初审通过':form.applyState===3?'初审不通过':form.applyState===4?'复审通过':form.applyState===5?'复审不通过':''"placeholder="请输入创建用户ID" disabled="disabled" />
      </el-form-item>
      <el-form-item label="创建用户ID" prop="createUserid">
        <el-input v-model="form.createUserid" placeholder="请输入创建用户ID" disabled="disabled" />
      </el-form-item>
      <el-form-item label="更新用户ID" prop="updateUserid">
        <el-input v-model="form.updateUserid" placeholder="请输入更新用户ID" disabled="disabled" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="dialog2=false">返回</el-button>
    </div>
  </el-dialog>
</div>
</template>


<script>
import { listInstallment,updateStatus2,updateStatus } from "@/api/message/installment";
export default {
  name: "index",
  data() {
    return {
      title1:'',
      title2:'',
      dialog:false,
      dialog2:false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 房租分期申请表格数据
      installmentList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 5,
        rentInstallmentOrderNo: null,
        outOrderNo: null,
        bussinessId: null,
        deptId: null,
        deptNo: null,
        cfContractId: null,
        rate: null,
        tenantRate: null,
        businessRate: null,
        loanAmount: null,
        monthLimit: null,
        serviceFee: null,
        jrProductId: null,
        reLeaseCount: null,
        inInterestCount: null,
        serCharge: null,
        coHirerentCount: null,
        remarks: null,
        auditMemo: null,
        applyState: null,
        delFlg: null,
        createUserid: null,
        updateUserid: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        rentInstallmentOrderNo: [
          { required: true, message: "房租分期申请单号不能为空", trigger: "blur" }
        ],
        outOrderNo: [
          { required: true, message: "外部合同号不能为空", trigger: "blur" }
        ],
        bussinessId: [
          { required: true, message: "商户ID不能为空", trigger: "blur" }
        ],
        deptId: [
          { required: true, message: "部门ID不能为空", trigger: "blur" }
        ],
        deptNo: [
          { required: true, message: "部门编号不能为空", trigger: "blur" }
        ],
        cfContractId: [
          { required: true, message: "出房合同ID不能为空", trigger: "blur" }
        ],
        rate: [
          { required: true, message: "利率不能为空", trigger: "blur" }
        ],
        tenantRate: [
          { required: true, message: "租客承担比例不能为空", trigger: "blur" }
        ],
        businessRate: [
          { required: true, message: "公寓承担比例不能为空", trigger: "blur" }
        ],
        loanAmount: [
          { required: true, message: "借款金额不能为空", trigger: "blur" }
        ],
        monthLimit: [
          { required: true, message: "借款期限不能为空", trigger: "blur" }
        ],
        serviceFee: [
          { required: true, message: "一次性服务费不能为空", trigger: "blur" }
        ],
        jrProductId: [
          { required: true, message: "金融产品ID不能为空", trigger: "blur" }
        ],
        applyState: [
          { required: true, message: "申请状态，1:申请中，2：初审通过，3：初审不通过，4：复审通过，5：复审不通过不能为空", trigger: "blur" }
        ],
        delFlg: [
          { required: true, message: "删除标识 0：未删除，1：删除不能为空", trigger: "blur" }
        ],
        createUserid: [
          { required: true, message: "创建用户ID不能为空", trigger: "blur" }
        ],
        createTime: [
          { required: true, message: "创建时间不能为空", trigger: "blur" }
        ],
        updateUserid: [
          { required: true, message: "更新用户ID不能为空", trigger: "blur" }
        ],
        updateTime: [
          { required: true, message: "更新时间不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods:{
    /**审核失败**/
    updateStatus2(){
      console.log(this.form)
      updateStatus2(this.form).then(Response =>{
        this.$modal.msgError("审核失败");
        this.dialog=false;
        this.getList();
      })
    },
    /**审核通过**/
    updateStatus(){
      updateStatus(this.form).then(Response =>{
        this.$modal.msgSuccess("审核成功!");
        this.dialog=false;
        this.getList();
      })
    },
    goUpdateStatus(row){
      this.form=row;
      this.dialog=true;
    },
    get(row){
      this.form=row;
      this.dialog2=true;
    },
    getList() {
      listInstallment(this.queryParams).then(res => {
        console.log(res)
        this.installmentList = res.list;
        this.total = res.total;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
  }
}
</script>

<style scoped>

</style>
